import { requestdata, fileUpdata } from "./baserequest"

//1.获取openid
const get_openid = (data, success, fail) => {
    requestdata("POST", data, "wx/get_openid", success, fail)
}


//2.更新用户信息
const update_info = (data, success, fail) => {
    requestdata("POST", data, "wx/update_info", success, fail)
}

//3.上传文件
const file_uploadone = (filePath, filename, success, fail, data) => {
    fileUpdata(filePath, filename, "file/uploadone", success, fail, data);
}

//4.拉取基本信息 || 拉取分享基本信息
const postcard_get = (data, success, fail) => {
    requestdata("POST", data, "postcard/get", success, fail);
}

//5.更新基本信息
const postcard_update = (data, success, fail) => {
    requestdata("POST", data, "postcard/update", function(res) {
        if (res.data.state == true) {
            wx.showToast({
                title: "成功！",
                icon: "success",
                mask: true
            })
        }
        success(res)
    }, fail);
}

//6.关注/取消关注
const user_follow = (data, success, fail) => {
    requestdata("POST", data, "user/follow", function(res) {
        if (res.data.state == true) {
            wx.showToast({
                title: "成功！",
                icon: "success",
                mask: true
            })
        }
        success(res)
    }, fail);
}

//7.拉取关注列表
const user_get_follow = (data, success, fail) => {
    requestdata("POST", data, "user/get_follow", success, fail);
}

//8.点赞接口
const user_start = (data, success, fail) => {
    requestdata("POST", data, "user/start", function(res) {
        if (res.data.state == true) {
            wx.showToast({
                title: "点赞成功！",
                icon: "none",
            })
        }
        success(res)
    }, fail);
}

//9.发送消息
const msg_add = (data, success, fail) => {
    requestdata("POST", data, "msg/add", function(res) { success(res) }, fail);
}

//10.获取消息
const msg_get = (data, success, fail) => {
    requestdata("POST", data, "msg/get", function(res) { success(res) }, fail);
}

//11.删除消息
const msg_delete = (data, success, fail) => {
    requestdata("POST", data, "msg/delete", function(res) { success(res) }, fail);
}
//12.申请个人名片
const postcard_request = (data, success,fail) =>{
    requestdata("POST", data, "postcard/request", function(res) { success(res) }, fail);
}

module.exports = {
    update_info: update_info,
    get_openid: get_openid,
    file_uploadone: file_uploadone,
    postcard_get: postcard_get,
    postcard_update: postcard_update,
    user_follow: user_follow,
    user_get_follow: user_get_follow,
    user_start: user_start,
    msg_add: msg_add,
    msg_get: msg_get,
    msg_delete: msg_delete,
    postcard_request:postcard_request
}